#ifndef __EGA__
#define __EGA__

#include "../lib/def.h"
#include "../lib/math.h"

#pragma pack(1)

typedef struct {
    WORD    bfType;
    DWORD   bfSize;
    WORD    bfReserved1;
    WORD    bfReserved2;
    DWORD   bfOffBits;
} BITMAPFILEHEADER, *PBITMAPFILEHEADER;

#pragma pack()

typedef struct {
    DWORD      biSize;
    LONG       biWidth;
    LONG       biHeight;
    WORD       biPlanes;
    WORD       biBitCount;
    DWORD      biCompression;
    DWORD      biSizeImage;
    LONG       biXPelsPerMeter;
    LONG       biYPelsPerMeter;
    DWORD      biClrUsed;
    DWORD      biClrImportant;
} BITMAPINFO, *PBITMAPINFO;

typedef struct {
    BYTE    rgbBlue;
    BYTE    rgbGreen;
    BYTE    rgbRed;
    BYTE    rgbReserved;
} RGBQUAD, *PRGBQUAD;

#pragma pack(1)

typedef struct {
    BITMAPFILEHEADER FileHdr;
    BITMAPINFO Info;
    RGBQUAD rgbColor[0];
} BITMAP, *PBITMAP;

#pragma pack()

typedef struct {
    LONG    left;
    LONG    top;
    LONG    right;
    LONG    bottom;
} RECT, *PRECT, *FAR LPRECT;

EXTERN RECT EgaScreenRect;

BOOL EgaInRect(LONG x, LONG y, LPRECT lpRect);
VOID EgaDrawPoint(PVECTOR2I pvPoint, BYTE bColor);
VOID EgaDrawTriangle(PVECTOR2I pvPoints, BYTE bColor);
STATUS EgaDrawBitmap(LPVOID lpvBitmap, WORD wX, WORD wY);
STATUS EgaDrawBitmapAlpha(LPVOID lpvBitmap, WORD wX, WORD wY, BYTE bAlpha);
STATUS EgaDrawBitmapLimited(LPVOID lpvBitmap, WORD wX, WORD wY, LPRECT lpRect);
STATUS EgaDrawBitmapAlphaLimited(LPVOID lpvBitmap, WORD wX, WORD wY, BYTE bAlpha, LPRECT lpRect);
VOID EgaSetPalettes(BYTE bStart, BYTE bLen, PRGBQUAD pColors);
VOID EgaDrawRect(LPRECT lpRect, BYTE bColor);
VOID EgaDrawBorder(LPRECT lpRect, LPRECT lpPadding, BYTE bColor);

#endif
